package com.tank.jdk8.stream;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * (1) 流框架的并行与串行
 * Created with IntelliJ IDEA.
 * User: SuQiEr
 * Date:2017/2/12
 * Time: 11:15
 * To change this template use File | Settings | File Templates.
 */
public class StreamTest8 {

    public static void main(String[] args) {

        /**
         * 需求：测试流的并行与串行执行效率
         * 分析：生成一个500万UUID集合对其排序
         */

        List<String> list = new ArrayList<>(5000000);
       for (int i = 0;i<5000000;i++){
           list.add(UUID.randomUUID().toString());
       }

        Long startTime = System.currentTimeMillis();
        //串行 11920
        //list.stream().sorted().count();
        //并行 6373
        list.parallelStream().sorted().count();
        Long endTime = System.currentTimeMillis();

        System.out.println("totle times:"+(endTime-startTime));

    }
}

